import unicodedata, re

class ActionBase:
    _action_token = ""
    _request = None
    
    _USER_ID_TOKEN = "user_id"
    _MESSAGE_KEY_TOKEN = "message_key"
    _MESSAGE_HASH_TOKEN = "message_hash"

    control_char_re = re.compile('[%s]' % re.escape(''.join(map(unichr, range(0,32) + range(127,160)))))
    
    def is_action(self, action):
        return self._action_token == action

    def set_request(self, request):
        self._request = request
        
    @classmethod
    def strip_non_printable(cls, data):
        return cls.control_char_re.sub('', data)
            